/*
* Copyright @ 2014 com.iflysse.trains
* manger_v2.0 下午4:48:48
* All right reserved.
*
*/
package com.iflysse.service;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.iflysse.dao.SiteInfoDao;
import com.iflysse.pojo.SiteInfo;
import com.iflysse.utils.MySessionFactory;

/**
 * @desc: manger_v2.0
 * @author: Administrator
 * @createTime: 2014年11月20日 下午4:48:48
 * @history:
 * @version: v1.0
 */
public class SiteInfoService {
	
	private SqlSessionFactory sf;
	
	public SiteInfoService(){
		sf = MySessionFactory.getSessionFactory();
	}

	public void insertSite(SiteInfo site){
		SqlSession session = sf.openSession();
		
		SiteInfoDao mapper = session.getMapper(SiteInfoDao.class);
		
		mapper.insertSite(site);
	
		session.commit();
		session.close();
	}
	
	public void updateSite(SiteInfo site){
		SqlSession session = sf.openSession();
		
		SiteInfoDao mapper = session.getMapper(SiteInfoDao.class);
		
		mapper.updateSite(site);
		
		session.commit();
		session.close();
	}
	
	public SiteInfo findSite(){
		SqlSession session = sf.openSession();
		
		SiteInfoDao mapper = session.getMapper(SiteInfoDao.class);
		SiteInfo site = mapper.findSitebyId(1);
		
		session.close();
		return site;
	}
}
